<?php
    // +----------------------------------------------------------------------
    // | ThinkPHP [ WE CAN DO IT JUST THINK ]
    // +----------------------------------------------------------------------
    // | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
    // +----------------------------------------------------------------------
    // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
    // +----------------------------------------------------------------------
    // | Author: liu21st <liu21st@gmail.com>
    // +----------------------------------------------------------------------
    Route::header('Access-Control-Allow-Origin', '*')
         ->header('Access-Control-Allow-Headers', 'Token, User-Agent, Keep-Alive, Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With')
         ->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, DELETE,OPTIONS')->allowCrossDomain();
    Route::get('think', function () {
        return 'hello,ThinkPHP5!';
    });

    Route::get('hello/:name', 'index/hello');

    Route::post('api/upload', 'api/upload/upload');

    //获取Token 需要权限
    Route::post('api/token/user', 'api/Token/getToken');
    //验证token
    Route::post('api/token/verify', 'api/Token/verifyToken');
    //app授权
    Route::post('api/token/app', 'api/Token/getAppToken');

    Route::group('api/account', function () {
        //发送验证码
        Route::post('send_captcha', 'api/account/getVerificationCode');
        //用户注册
        Route::post('register_user', 'api/account/registerUser');
        //用户登陆
        Route::post('user_login', 'api/account/login');
        //忘记密码
        Route::post('edit_password', 'api/account/forgetPassword');
        //跑男认证信息上传
        Route::post('certification', 'api/account/certification');
        //跑男认证通过
        Route::post('certification_pass', 'api/account/certificationPass');
        //判断用户是否注册
        Route::post('is_registered', 'api/account/isRegistered');
        //用户页面选择
        Route::post('select_role/:id', 'api/account/selectRole');
        //获取用户信息
        Route::post('account_info', 'api/account/getAccountInfo');

        //后台管理登陆
        Route::post('login', 'api/AdminLogin/verify')->allowCrossDomain();

        Route::post('login_out', 'api/AdminLogin/loginOut');

        //管理员获取所有接口
        Route::get('get_all_user', 'api/Account/getUsers');

        //获取跑男用户
        Route::get('get_runningman', 'api/Account/getRunningman');

        //跑男认证状态改变
        Route::post('change_state', 'api/Account/changeState');

        //保存微信授权信息
        Route::post('save_wx_info', 'api/Account/saveWxUserInfo');

        //获取所有已注册的用户
        Route::get('get_account_count', 'api/Account/getAccountCount');

        //获取所有跑男
        Route::get('get_runningman_count', 'api/Account/getRunningManCount');



    });

    Route::group('api/university', function () {
        //大学保存
        Route::post('save', 'api/University/save');
        //大学编辑
        Route::post('edit', 'api/University/edit');
        //大学删除
        Route::post('delete', 'api/University/delete');
        //获取当前所在大学
        Route::get('get_current_university', 'api/University/getCurrentUniversity');
        //获取最近的10个大学
        Route::get('get_recent_university', 'api/University/getRecentuniversity');
        //获取所有大学
        Route::get('get_all_university', 'api/University/getAllUniversity');
        //获取大学下的所有商品类型 并转化
        Route::get('get_university_with_type', 'api/GoodsType/getUniversityWithType');
    });

    Route::group('api/goodstype', function () {
        //商品类别新增
        Route::post('create', 'api/GoodsType/createGoodsType');
        //商品类别编辑
        Route::post('edit', 'api/GoodsType/edit');
        //获取指定大学下的所有商品类别
        Route::get('get_goodstype_by_universityid/:id', 'api/GoodsType/getAllGoodsTypeByUniversityId');

        Route::get('get_all_type', 'api/GoodsType/getAllType');
    });

    Route::group('api/goods', function () {
        //商品新增
        Route::post('create', 'api/Goods/createGoods');

        //获取所有商品
        Route::get('get_all_goods', 'api/Goods/getAllGoods');
        //编辑商品
        Route::post('edit', 'api/Goods/editGoods');

        //删除商品
        Route::post('delete', 'api/Goods/delete');
    });

    Route::group('api/harvestaddress', function () {
        //新增收货地址
        Route::post('create', 'api/HarvestAddress/create');
        //新增取货地址
        Route::post('create_receiver_address', 'api/HarvestAddress/createReceiver');
        //获取收货地址 获取取货地址
        Route::get('get_harvestaddress/:university_id/:type', 'api/HarvestAddress/getAddress');
        //获取指定地址
        Route::get('get_harvestaddress_by_id/:id', 'api/HarvestAddress/getAddressById');
        //修改收货地址
        Route::post('edit', 'api/HarvestAddress/save');
        //修改取货地址
        Route::post('editReceiver', 'api/HarvestAddress/saveReceiver');
        //修改默认收货地址  修改默认取货地址
        Route::post('edit_default_address', 'api/HarvestAddress/editDefault');
        //获取默认收货地址 获取默认取货地址
        Route::get('get_default_address/:id/:type', 'api/HarvestAddress/getDefaultAddress');
    });

    Route::group('api/voucher', function () {
        //优惠卷新增
        Route::post('create', 'api/Voucher/createVoucher');
        //用户领取优惠卷
        Route::post('account_get_voucher', 'api/Voucher/accountGetVouchers');
        //获取当前用户优惠卷
        Route::get('get_account_vouchers', 'api/Voucher/getAccountVouchers');
    });

    Route::group('api/order', function () {
        //帮我买 下单处理
        Route::post('place', 'api/Order/placeOrder');
        //帮我取 下订单
        Route::post('recevier_place', 'api/Order/receiverPlaceOrder');
        //获取跑男端可接订单
        Route::get('get_can_recevice_orders', 'api/Order/getCanOrderable');
        //跑男立即接单
        Route::post('immediately_order', 'api/Order/immediatelyOrder');
        //跑男确认送达
        Route::post('confirmed_delivery', 'api/Order/confirmedDelivery');
        //用户端确认收货
        Route::post('confirmed_receipt', 'api/Order/confirmReceipt');
        //跑男端未完成订单
        Route::post('incomplete_orders', 'api/Order/incompleteOrders');
        //跑男端已完成订单
        Route::post('completed_order', 'api/Order/completedOrder');
        //用户端进行中订单
        Route::post('ongoing_orders', 'api/Order/onGoingOrder');
        //用户端已结束订单
        Route::post('ended_orders', 'api/Order/endedOrder');
        //获取订单 通过 订单id
        Route::get('get_order_by_id/:id', 'api/Order/getOrderById');
        //联系跑男
        Route::post('call_phone_by_account', 'api/Order/callPhoneByAccount');
        //获取营业额
        Route::get('get_all_money', 'api/Order/getAllMoney');

        //获取所有订单
        Route::get('get_all_order','api/Order/getAllOrder');
        //取消订单
        Route::post('cancle_order', 'api/Order/cancleOrder');

        //退款
        Route::post('order_refund', 'api/Order/refund');


    });

    Route::group('api/pay', function () {
        //付款
        Route::post('pre_order', 'api/Pay/getPreOrder');
        //付款回调
        Route::post('notify', 'api/Pay/receiveNotify');
    });

    //获取所有重量
    Route::group('api/weight', function () {
        //获取所有重量
        Route::get('get', 'api/Weight/getWeight');
    });

    //获取所有取货商品类型
    Route::group('api/pickupgoods', function () {
        //获取所有重量
        Route::get('get', 'api/PickUpGoods/getPickUpGoods');
    });


    //提现相关
    Route::group('api/withdrawal', function () {
        //提现
        Route::post('create', 'api/Withdrawal/create');
        //提现记录
        Route::post('get_record_list', 'api/Withdrawal/getRecordList');
        //获取所有记录
        Route::get('get_all_record_list', 'api/Withdrawal/getAllRecordList');
        //审核通过
        Route::post('state_pass', 'api/Withdrawal/statePass');
        //审核失败
        Route::post('state_refuse', 'api/Withdrawal/stateRefuse');
    });

    //轮播图
    Route::group('api/ad', function () {
        //新增
        Route::post('create', 'api/Ad/create');
        Route::post('edit', 'api/Ad/edit');
        Route::post('delete', 'api/Ad/delete');
        Route::get('get', 'api/Ad/get');
    });



    Route::miss(function () {
        return [
            'msg'        => 'your required resource are not found',
            'error_code' => 10001,
        ];
    });

    return [

    ];